From 5bc6f1ef3d7c45c413145b466d8502c3b913c83e Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Thu, 1 Dec 2005 03:19:40 +0000 Subject: [PATCH] Added a pages_to_kib function, which converts a page count into a number of KiB. This allows us to compute the correct amount to balloon out to support a migration. Signed-off-by: Ewan Mellor --- tools/python/xen/lowlevel/xc/xc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 29f64641d6..95b0a9f101 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -576,6 +576,17 @@ static PyObject *pyxc_readconsolering(XcObject *self, } +static PyObject *pyxc_pages_to_kib(XcObject *self, PyObject *args) +{ + unsigned long pages; + + if (!PyArg_ParseTuple(args, "l", &pages)) + return NULL; + + return PyLong_FromUnsignedLong(pages * (XC_PAGE_SIZE / 1024)); +} + + static unsigned long pages_to_mb(unsigned long pages) { return (pages * (XC_PAGE_SIZE / 1024) + 1023) / 1024; @@ -1059,6 +1070,12 @@ static PyMethodDef pyxc_methods[] = { " allow_access [int]: Non-zero means enable access; else disable access\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, + { "pages_to_kib", + (PyCFunction)pyxc_pages_to_kib, + METH_VARARGS, "\n" + "Returns: [int]: The size in KiB of memory spanning the given number " + "of pages.\n" }, + { NULL, NULL, 0, NULL } }; -- 2.30.2